package com.welove.adapter;

import java.util.ArrayList;
import java.util.List;

import com.welove.R;

import android.content.Context;
import android.graphics.Point;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.FrameLayout;
import android.widget.GridView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;


public class UnLoginGridAdapter extends BaseAdapter{

	private GridView gv;
	private Point imagePoint;
	  public static class Item{
	        public String text;
	        public int resId;
	    }

	    private List<Item> mItems = new ArrayList<UnLoginGridAdapter.Item>();
	    private Context mContext;
	    public UnLoginGridAdapter(Context context) {
	       
	        for (int i = 0; i <18; i++) {
	            Item object = new Item();
	            object.text = "Text "+i;
	            object.resId = R.drawable.grid_item_test;
	            mItems.add(object);
	        }
	      
	        mContext = context;
	      
	    }

	    @Override
	    public int getCount() {
	        return mItems.size();
	    }

	    @Override
	    public Object getItem(int position) {
	        return mItems.get(position);
	    }

	    @Override
	    public long getItemId(int position) {
	        return position;
	    }

	    @Override
	    public View getView(int position, View convertView, ViewGroup parent) {
	    	ViewHolder viewHolder;
	        if(convertView == null) {
	        	viewHolder=new ViewHolder();
	            convertView = LayoutInflater.from(mContext).inflate(R.layout.unlogin_gv_item, null);
	          
		      
	            viewHolder.unlogin_iv_item= (ImageView) convertView.findViewById(R.id.unlogin_iv_item);
	           
	           
	            viewHolder.unlogin_tv_item= (TextView) convertView.findViewById(R.id.unlogin_tv_item);
	          
	            convertView.setTag(viewHolder);
	        }
	        else {
				viewHolder=(ViewHolder) convertView.getTag();
			}
	     
	     
	        viewHolder.unlogin_iv_item.setImageResource(mItems.get(position).resId);
	        viewHolder.unlogin_tv_item.setText(mItems.get(position).text);
	        return convertView;
	    }
	    
	    private class ViewHolder
	    {
	    	private ImageView unlogin_iv_item;
	    	private TextView unlogin_tv_item;
	    }
}
